package cc.wsyw126.java.collection.set;

import java.util.HashSet;

/**
 * Created by junpeng.yang on 16/8/25.
 */
public class HashSetTest {


    public static void main(String[] args) {
        HashSet objs = new HashSet();
        objs.add(new EuqalsObj());
        objs.add(new EuqalsObj());
        objs.add(new HashCodeObj());
        objs.add(new HashCodeObj());
        objs.add(new HashSetObj());
        objs.add(new HashSetObj());
        System.out.println("HashSet Elements:");
        objs.forEach(n -> { System.out.print(n+"\t"); System.out.println(n.hashCode());});

    }
}

class EuqalsObj {
    public boolean equals(Object obj) {
        return true;
    }
}

class HashCodeObj {
    public int hashCode() {
        return 1;
    }
}


class HashSetObj {
    public int hashCode() {
        return 2;
    }

    public boolean equals(Object obj) {
        return true;
    }
}